#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 20, INF = 0x3f3f3f3f;

int d[4][2] = { 1,0,-1,0,0,1,0,-1 };
int mp[N][N];
bool vis[N][N];

int bfs(int sx, int sy, int b)
{
    queue<pair<int, int>> q, del;
    q.push({ sx,sy });vis[sx][sy] = 1;
    del.push({ sx, sy });
    while (!q.empty()) {
        auto [x, y] = q.front();q.pop();
        for (int i = 0;i < 4;i++) {
            int nx = x + d[i][0], ny = y + d[i][1];
            if (nx >= 1 && nx <= 19 && ny >= 1 && ny <= 19) {
                if (mp[nx][ny] == 0) {
                    while (!del.empty()) {
                        pair<int, int> t = del.front();del.pop();
                        vis[t.first][t.second] = 0;
                    }
                    return 0;
                } else if (mp[nx][ny] == b && vis[nx][ny] == 0) {
                    q.push({ nx,ny });vis[nx][ny] = 1;
                    del.push({ nx,ny });
                }
            }
        }

    }
    int res = del.size();
    while (!del.empty()) {
        pair<int, int> t = del.front();del.pop();
        mp[t.first][t.second] = vis[t.first][t.second] = 0;
    }
    return res;
}

void print()
{
    cout << "---------------\n";
    for (int i = 1;i <= 19;i++) {
        for (int j = 1;j <= 19;j++)
            cout << mp[i][j] << ' ';
        cout << '\n';
    }
    cout << "\n------------------\n";
}

void solve()
{
    int m;cin >> m;
    for (int i = 1;i <= m;i++) {
        int x, y; cin >> x >> y;
        int ans1 = 0, ans2 = 0;
        if (i % 2 == 1) {
            mp[x][y] = 1;
            for (int i = 0;i < 4;i++) {
                int nx = x + d[i][0], ny = y + d[i][1];
                if (nx >= 1 && nx <= 19 && ny >= 1 && ny <= 19 && mp[nx][ny] == 2) ans2 += bfs(nx, ny, 2);
            }
            if (ans2 == 0)  ans1 = bfs(x, y, 1);
            cout << ans1 << ' ' << ans2 << '\n';
        } else {
            mp[x][y] = 2;
            for (int i = 0;i < 4;i++) {
                int nx = x + d[i][0], ny = y + d[i][1];
                if (nx >= 1 && nx <= 19 && ny >= 1 && ny <= 19 && mp[nx][ny] == 1) ans1 += bfs(nx, ny, 1);
            }
            if (ans1 == 0)  ans2 = bfs(x, y, 2);
            cout << ans1 << ' ' << ans2 << '\n';
        }
        // print();
    }
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}